package io.dy.guarded_extend;

import io.dy.utils.ThreadUtils;

/**
 * @author dmj
 * @date 2024年03月22日 下午5:21
 */
public class Person extends Thread{

    private final GuardedContainer<String> guardedContainer;

    public Person(GuardedContainer<String> guardedContainer) {
        this.guardedContainer = guardedContainer;
    }

    @Override
    public void run() {
        //收信 创建收信盒
        GuardedObject<String> guardedObject = guardedContainer.createGuardedObject();
        ThreadUtils.printThreadLog("收信 id:" + guardedObject.getId());
        String value = guardedObject.getValue(5000);
        ThreadUtils.printThreadLog("收信内容 :" + value);
    }
}
